
#include "gamemanager.h"
#include "resourcemanager.h"
#include "messagequeue.h"

GameManager* GameManager::_instance = nullptr;

GameManager::GameManager() :
xscale(0.0f)
, yscale(0.0f)
, minscale(0.0f)
, _playScene(nullptr)
{
    screenSize = Director::getInstance()->getWinSize();
    xscale = screenSize.width / BASE_WIDTH;
    yscale = screenSize.height / BASE_HEIGHT;
    minscale = (xscale < yscale ? xscale : yscale);

	dpi = Device::getDPI();

	log("width: %0.0f, height:%0.0f, x scale:%0.2f, y scale:%0.2f, min scale:%0.2f, dpi:%d", 
		screenSize.width, screenSize.height, xscale, yscale, minscale, dpi);
}

GameManager::~GameManager() {

}

GameManager* GameManager::getInstance() {
    if (_instance == nullptr) {
        _instance = new GameManager();
    }
    return _instance;
}

cocos2d::Point GameManager::getParentCenterPosition( Node* parent )
{
	Size size = parent->getContentSize();
	return Point(size.width / 2.0, size.height / 2.0f);
}

cocos2d::Point GameManager::getLogicPosition( const Point& pt )
{
	return Point(pt.x / GM->xscale, pt.y / GM->yscale);
}

GamePlayScene* GameManager::getGamePlayScene()
{
	return _playScene;
}

void GameManager::setGamePlayScene( GamePlayScene* scene )
{
	_playScene = scene;
}

